package com.dj.ms.support.plus;

import com.dj.ms.support.ConfigProcessor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

/**
 * <br>
 * <p>获取数据源配置信息--使用spring默认配置key</p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/9/29 上午9:57
 */
@Slf4j
@Setter
@Getter
@Configuration
public class PlusDataSourceConfig {

    /**
     * 链接地址
     */
    private String url;

    /**
     * 数据库用户名称
     */
    private String username;

    /**
     * 数据库用户密码
     */
    private String password;

    /**
     * 当前数据源链接驱动
     */
    private String driverClassName;

    public static class Processor implements ConfigProcessor<PlusDataSourceConfig> {
        private final PlusDataSourceConfig plusDataSourceConfig;
        public Processor() {
            this.plusDataSourceConfig = new PlusDataSourceConfig();
        }

        public Processor url(String url) {
            plusDataSourceConfig.url = url;
            return this;
        }
        public Processor username(String username) {
            plusDataSourceConfig.username = username;
            return this;
        }
        public Processor password(String password) {
            plusDataSourceConfig.password = password;
            return this;
        }
        public Processor driverClassName(String driverClassName) {
            plusDataSourceConfig.url = driverClassName;
            return this;
        }

        @Override
        public PlusDataSourceConfig process() {
            return plusDataSourceConfig;
        }
    }

}
